package com.qk.management.controller;

import com.qk.common.PageResult;
import com.qk.common.Result;
import com.qk.domain.business.BusinessCustomerDO;
import com.qk.domain.customers.CustomersDO;
import com.qk.domain.user.UserDO;
import com.qk.dto.customer.CustomerAddDTO;
import com.qk.dto.customer.CustomerDTO;
import com.qk.dto.user.UserDTO;
import com.qk.management.aop.anno.LogAnno;
import com.qk.management.service.CustomersService;
import com.qk.vo.business.BusinessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customers")
public class CustomersController {
    @Autowired
    private CustomersService customersService;
    @GetMapping
    public Result list(CustomerDTO dto){
        PageResult<CustomersDO> pageResult =customersService.list(dto);
        return Result.success(pageResult);
    }
    @LogAnno
    @PostMapping
    public Result addCustomer(@RequestBody CustomerAddDTO dto) {
        customersService.addCustomer(dto);
        return Result.success();
    }
    @LogAnno
    @GetMapping("/{id}")
    public Result getById(@PathVariable("id") Integer id){
        BusinessCustomerDO vo =customersService.getByCusId(id);
        return Result.success(vo);
    }
    //修改客户
    @LogAnno
    @PutMapping
    public Result update(@RequestBody BusinessCustomerDO dto){
        customersService.updateBy(dto);
        return Result.success();
    }
}
